package com.wind.bean;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *  @ConfigurationProperties(prefix = "persion") ：注解是将JavaBean的属性和配置文件前缀为xxx的一一绑定。
 *  @Value("")：要一个一个指定
 *  @PropertySource(value = {"classpath:application.yml"}) 加载指定的配置文件；注意 不是@PropertySources
 */
@Component
@PropertySource(value = {"classpath:application.yml"})
@ConfigurationProperties(prefix = "persion")
@Validated
public class Persion {

    /*
        xml获取配置文件的值？
            <bean class="Persion">
                <property name="lastName" value="可以是字面量...指定值 / 还可以是${kay}：从配置文件中取值"></property>
            </bean>
     */
    // @Value("${persion.last-name}")
    // @Email // JSR303校验
    private String lastName;
    // @Value("#{11*2}")
    private Integer age;
    // @Value("true")
    private Boolean boss;
    private Date birth;
    private Map maps;
    private List list;
    private Dog dog;

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Boolean getBoss() {
        return boss;
    }

    public void setBoss(Boolean boss) {
        this.boss = boss;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public Map getMaps() {
        return maps;
    }

    public void setMaps(Map maps) {
        this.maps = maps;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    @Override
    public String toString() {
        return "Persion{" +
                "lastName='" + lastName + '\'' +
                ", age=" + age +
                ", boss=" + boss +
                ", birth=" + birth +
                ", maps=" + maps +
                ", list=" + list +
                ", dog=" + dog +
                '}';
    }
}
